import request from '@/utils/request'

//获取树形列表
export const getDepartments=() => {
  return request ({
    url:'/company/department',
  })
}
//增加子部门
interface Data {
  pid: string;
  name: string;
  code: string;
  manager: string;
  introduce: string;
}
export function addDepartments(data:Data) {
  return request({
    url: '/company/department',
    method: 'post',
    data,
  })
}

//根据id获取子部门的详情
export function getDepartmentsById(id:string) {
  return request({
    url: `/company/department/${ id }`,
  })
}
//编辑部门
export function updateDepartments(data:UpdateDepartments) {
  return request({
    url: `/company/department/${ data.id }`,
    method: 'put',
    data,
  })
}
/**
 * @description: 删除部门
 * @param {*} id 当前点击的操作按钮 所在的项的id
 * @return {*}
 */
export function delDepartment(id:string) {
  return request({
    url: `/company/department/${ id }`,
    method: 'delete',
  })
}
